import request from "@/api/request.ts";

// 获取系统角色分页数据
export const getRuleByPage = (
  params: SysRoleEntityRequestParams
): Promise<apiServerResponse> => {
  return request({
    url: "/sysRole/roleByPage",
    method: "GET",
    params,
  });
};

// 新增系统角色
export const addRule = (data: SysRoleEntity): Promise<apiServerResponse> => {
  return request({
    url: "/sysRole/add",
    method: "POST",
    data,
  });
};
// 修改系统角色
export const updateRule = (data: SysRoleEntity): Promise<apiServerResponse> => {
  return request({
    url: "/sysRole/update",
    method: "PUT",
    data,
  });
};

// 删除系统角色
export const removeRuleById = (id: string): Promise<apiServerResponse> => {
  return request({
    url: `/sysRole/deleteById/${id}`,
    method: "DELETE",
  });
};

// 获取角色下已授权菜单
export const getRoleByMenus = (
  params: SysRoleEntityRequestParams
): Promise<apiServerResponse> => {
  return request({
    url: "/sysRole/getRoleByMenus",
    method: "GET",
    params,
  });
};
//给角色授权菜单
export const roleAuthorizeMenus = (
  data: RoleAuthorizeMenusRequestParams
): Promise<apiServerResponse> => {
  return request({
    url: `/sysRole/roleAuthorizeMenus`,
    method: "POST",
    data,
  });
};
//获取角色下已授权用户
export const getRoleByAuthorizedUsers = (
  params: SysRoleEntityRequestParams
): Promise<apiServerResponse> => {
  return request({
    url: "/sysRole/getRoleAuthorize",
    method: "GET",
    params,
  });
};
//获取角色下待授权用户
export const getRoleByUnauthorizedUsers = (
  params: SysRoleEntityRequestParams
): Promise<apiServerResponse> => {
  return request({
    url: "/sysRole/getRoleNoAuthorizeUsers",
    method: "GET",
    params,
  });
};

//给角色授权用户
export const roleAuthorizeUsers = (
  data: RoleAuthorizeUserRequestParams
): Promise<apiServerResponse> => {
  return request({
    url: `/sysRole/roleAuthorizeUsers`,
    method: "POST",
    data,
  });
};
